<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>cocos.actions.move_actions</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body>
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar">
  <tr valign="middle">
  <!-- Project homepage -->
      <!--<th class="navbar" 
            ><a class="navbar" target="_top" href="http://www.cocos2d.org/">cocos2d API reference</a></th>-->

  <!-- Tree link -->
      <th><a
        href="module-tree.html">Trees</a></th>

  <!-- Index link -->
      <th><a
        href="identifier-index.html">Indices</a></th>

  <!-- Breadcrumbs -->
      <th class="navbar-breadcrumbs">
        <span class="breadcrumbs">
          <a href="cocos-module.html">cocos</a>&nbsp;.&nbsp;<a href="cocos.actions-module.html">actions</a>&nbsp;.&nbsp;move_actions
        </span>
      </th>

      <th class="navbar last">
        <a href="javascript:toggleFrames()">Toggle&nbsp;frames</a>
      </th>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module cocos.actions.move_actions</h1>
<p>Actions for moving things around based on their velocity and
acceleration.</p>
<p>The simplest usage:</p>
<blockquote>
sprite = cocos.sprite.Sprite('ship.png')
sprite.velocity = (100, 100)
sprite.do(Move())</blockquote>
<p>This will move the sprite (100, 100) pixels per second indefinitely.</p>
<p>Typically the sprite would be controlled by the user, so something like:</p>
<pre class="py-doctest">
<span class="py-builtin">keys</span> = &lt;standard pyglet keyboard state handler&gt;

<span class="py-keyword">class</span> <span class="py-defname">MoveShip</span>(Move):
   <span class="py-keyword">def</span> <span class="py-defname">step</span>(self, dt):
       super(MoveShip, self).step(dt)
       self.target.dr = (<span class="py-builtin">keys</span>[key.RIGHT] - <span class="py-builtin">keys</span>[key.LEFT]) * 360
       rotation = math.pi * self.target.rotation / 180.0
       rotation_x = math.cos(-rotation)
       rotation_y = math.sin(-rotation)
       <span class="py-keyword">if</span> <span class="py-builtin">keys</span>[key.UP]:
           self.target.acceleration = (200 * rotation_x, 200 * rotation_y)

ship.do(MoveShip())</pre>

<!-- ==================== CLASSES ==================== -->
<a name="section-Classes"></a>
        <h2>Classes</h2>
<table class="summary">
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="cocos.actions.move_actions.Move-class.html" class="summary-name">Move</a>
<div class="summary-description">Move the target based on parameters on the target.</div>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="cocos.actions.move_actions.WrappedMove-class.html" class="summary-name">WrappedMove</a>
<div class="summary-description">Move the target but wrap position when it hits certain bounds.</div>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="cocos.actions.move_actions.BoundedMove-class.html" class="summary-name">BoundedMove</a>
<div class="summary-description">Move the target but limit position when it hits certain bounds.</div>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="cocos.actions.move_actions.Driver-class.html" class="summary-name">Driver</a>
<div class="summary-description">Drive a <a href="cocos.cocosnode.CocosNode-class.html" class="link">CocosNode</a> object around like a car in x, y according to
a direction and speed.</div>
    </td>
  </tr>
</table>
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar">
  <tr valign="middle">
  <!-- Project homepage -->
      <!--<th class="navbar" 
            ><a class="navbar" target="_top" href="http://www.cocos2d.org/">cocos2d API reference</a></th>-->

  <!-- Tree link -->
      <th><a
        href="module-tree.html">Trees</a></th>

  <!-- Index link -->
      <th><a
        href="identifier-index.html">Indices</a></th>

  <!-- Breadcrumbs -->
      <th class="navbar-breadcrumbs">
        <span class="breadcrumbs">
          <a href="cocos-module.html">cocos</a>&nbsp;.&nbsp;<a href="cocos.actions-module.html">actions</a>&nbsp;.&nbsp;move_actions
        </span>
      </th>

      <th class="navbar last">
        <a href="javascript:toggleFrames()">Toggle&nbsp;frames</a>
      </th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0beta1 on Wed Oct 26 10:00:10 2011
    </td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
